from django.apps import AppConfig

class ApiConfig(AppConfig):
    name = 'api'

    def ready(self):
        try:
            from core.config import EXEC_REGIST_METHOD,cfg
            from core.log import logging
            from core.register import RegisterRpc,RegisterConfig,RegisterPermission,RegisterEvent
            for o in EXEC_REGIST_METHOD:
                method= o.upper()
                if method=="RPC":
                    RegisterRpc(cfg.RPC_REGIST_TYPE)
                elif method=="CONFIGURE":
                    RegisterConfig()
                elif method=="PERMISSION":
                    RegisterPermission()
                elif method=="EVENT":
                    RegisterEvent()
                else:
                    logging.error("regist method error. error key(%s)"%o)
        except Exception as e:
            logging.error(e)
